<#include "EntityCommonVisit.ftl">
package ${packageName};

import org.jow.core.db.DBConsts;
import org.jow.core.Port;
import org.jow.core.Record;
import org.jow.common.entrepot.Entrepot;
import ${superClassPackage}.${superClassName};
import org.jow.core.gen.JowGenFile;

@JowGenFile
public abstract class ${entityName} extends ${superClassName} {
	public ${entityName}() {
		super();
	<#list fields as field>
		<#if field.defaults??>
			<#if field.type == "String">
		set${field.name?cap_first}("${field.defaults}");
			<#else>
		set${field.name?cap_first}(${field.defaults});
			</#if>
		</#if>
	</#list>
	}

	public ${entityName}(Record record) {
		super(record);
	<#list fields as field>
		<#if field.isTransient>
		<#if field.defaults??>
			<#if field.type == "String">
		set${field.name?cap_first}("${field.defaults}");
			<#else>
		set${field.name?cap_first}(${field.defaults});
			</#if>
		</#if>
		</#if>
	</#list>
	}
	
	/**
	 * 属性关键字
	 */
	public static class SuperK {
		<#list fields as field>
		/** ${field.comment} */
		public static final String ${field.name} = "${field.name}";
		</#list>
	}

	/**
	 * 获取指定字段值
	 * 
	 * @param key
	 * @return
	 */
	@SuppressWarnings("unchecked")
	public <T> T getField(String key) {
		Object value = null;
		if (key == null) {
			return (T) value;
		}
		switch (key) {
		<#list fields as field>
			case SuperK.${field.name}: {
			<#if field.type!="boolean">
				value = get${field.name?cap_first}();
			<#else>
			<#-- *************布尔类型进行特殊处理 独有的属性调用函数*********** -->
				value = is${field.name?cap_first}();
			</#if>
				break;
			}
		</#list>
			default: break;
		}
		
		return (T) value;
	}
	
	public void setField(String key, Object value) {
		if (key == null) {
			return;
		}

		switch (key) {
		<#list fields as field>
			case SuperK.${field.name}: {
				set${field.name?cap_first}((${field.type}) value);
				break;
			}
		</#list>
			default: break;
		}
	}

	<#-- get和set方法 -->
	<@getAndSetField fields=fields />

	private String getHumanKey() {
		return "";
	}
}